package com.imc.api.order.repository;

import com.imc.api.order.pojo.OrderDetail;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.Set;

/*
 * 类描述：订单详情操作仓库
 * 开发者：tanweiping
 * 创建日期：2018/10/28 21:28
 */
public interface IWxOrderDetailRepository extends
        JpaRepository <OrderDetail, Integer>, JpaSpecificationExecutor <OrderDetail> {

    /*
     * YT  2018/10/28 21:28
     * 方法描述：通过订单ID查询商品列表
     */
    @Query(
            value = "SELECT DISTINCT detail.goodsId FROM t_order_detail detail WHERE detail.orderId = :orderId",
            nativeQuery = true
    )
    Set <String> findGoodsIdsByOrderId(@Param("orderId") Integer orderId);
}
